using EasyAdmin.Admin.Entity.Entities;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace EasyAdmin.Admin.Application.Services
{
    public interface ISysMenuService
    {
        /// <summary>
        /// 获取菜单树形结构
        /// </summary>
        /// <param name="userId">用户ID，用于获取用户权限下的菜单</param>
        /// <returns>菜单树形结构</returns>
        Task<List<MenuTreeDto>> GetMenuTreeAsync(long? userId = null);

        /// <summary>
        /// 获取菜单列表
        /// </summary>
        /// <param name="keyword">搜索关键词</param>
        /// <returns>菜单列表</returns>
        Task<List<SysMenu>> GetMenuListAsync(string keyword = null);

        /// <summary>
        /// 获取菜单详情
        /// </summary>
        /// <param name="menuId">菜单ID</param>
        /// <returns>菜单详情</returns>
        Task<SysMenu> GetMenuByIdAsync(int menuId);

        /// <summary>
        /// 创建菜单
        /// </summary>
        /// <param name="menu">菜单信息</param>
        /// <returns>创建结果</returns>
        Task<(bool Success, string Message)> CreateMenuAsync(SysMenu menu);

        /// <summary>
        /// 更新菜单
        /// </summary>
        /// <param name="menu">菜单信息</param>
        /// <returns>更新结果</returns>
        Task<(bool Success, string Message)> UpdateMenuAsync(SysMenu menu);

        /// <summary>
        /// 删除菜单
        /// </summary>
        /// <param name="menuId">菜单ID</param>
        /// <returns>删除结果</returns>
        Task<(bool Success, string Message)> DeleteMenuAsync(int menuId);

        /// <summary>
        /// 获取角色的菜单权限
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <returns>菜单ID列表</returns>
        Task<List<int>> GetRoleMenuIdsAsync(int roleId);

        /// <summary>
        /// 获取用户的菜单权限标识
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>权限标识列表</returns>
        Task<List<string>> GetUserPermissionsAsync(int userId);
    }

    /// <summary>
    /// 菜单树形结构DTO
    /// </summary>
    public class MenuTreeDto
    {
        /// <summary>
        /// 菜单ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 父菜单ID
        /// </summary>
        public int ParentId { get; set; }

        /// <summary>
        /// 菜单名称
        /// </summary>
        public string MenuName { get; set; }

        /// <summary>
        /// 路由地址
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// 组件路径
        /// </summary>
        public string Component { get; set; }

        /// <summary>
        /// 权限标识
        /// </summary>
        public string Perms { get; set; }

        /// <summary>
        /// 菜单图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 显示顺序
        /// </summary>
        public int OrderNum { get; set; }

        /// <summary>
        /// 菜单类型
        /// </summary>
        public string MenuType { get; set; }

        /// <summary>
        /// 是否显示
        /// </summary>
        public int Visible { get; set; }

        /// <summary>
        /// 子菜单列表
        /// </summary>
        public List<MenuTreeDto> Children { get; set; } = new List<MenuTreeDto>();
    }
}